import { useEffect, useState } from "react";

const DynamicIcon = ({ type }: { type: string }) => {
	const [AntIcon, setAntIcon] = useState(null); // 定义一个状态来保存动态导入的 Ant Design 组件
	console.log(`@ant-design/icons/dist/icons/${type}`);
	useEffect(() => {
		// 使用import()函数动态导入 Ant Design 组件
		import(`@ant-design/icons/dist/icons/${type}`).then(module => {
			console.log(module);
			setAntIcon(module.default);
		});
	}, [type]);

	if (AntIcon) {
		// @ts-ignore
		return <AntIcon />;
	}

	return <div></div>;
};

export default DynamicIcon;
